<?php
declare (strict_types = 1);

namespace app\controller;

use app\facade\Param;
use app\helpers\api\ApiResponse;
use app\model\Signup;
use app\model\User;
use think\facade\Db;
use think\Request;

class UserController
{
    use ApiResponse;
    /**
     * 用户列表
     *
     * @return \think\Response
     */
    public function index(Request $request)
    {
        $query = User::field('id,name');
        $query = Param::userParam($request->param(), $query);
        return $this->success($query->paginate($request->param('page_size', 15)));
    }

    //用户详情
    public function show(User $user)
    {
        //密码字段不返回
        unset($user->password);
        return $this->success($user);
    }

    //获取天气信息
    public function way(Request $request)
    {
        header("Content-type: application/json; charset=utf-8");
        $params = array(
            'city' => $request->param('city'),
            'appkey' => '30f63d51203f072f4a1e91ed87795fe4'
        );
        $url = 'https://way.jd.com/he/freeweather';
        $way =  wx_http_request($url, $params );
        $res = json_decode($way,true);
        return $this->success($res);
    }



}
